import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/Home.vue'

Vue.use(VueRouter)

//解决路由重复跳转
const routerPush = VueRouter.prototype.push

VueRouter.prototype.push = function (location) {
  return routerPush.call(this, location).catch((err) => err)
}

const routes = [
  {
    path: '/',
    name: 'home',
    component: Home,
    meta: {
      title: '烘培帮',
      hideTabBar: false,
    },
    children: [
      {
        path: `dis`,
        name: 'Dis',
        component: () => import('../views/dis.vue'),
      },
    ],
  },
  {
    path: '/show',
    name: 'show',
    meta: {
      title: '烘培帮_烘培秀秀_烘培帮',
      hideTabBar: false,
    },
    component: () => import('../views/Show.vue'),
  },
  {
    path: '/questionAndAnswer',
    name: 'questionAndAnswer',
    meta: {
      title: '烘培问答_烘培社区_烘培交流_烘培帮',
      hideTabBar: false,
    },
    component: () => import('../views/QuestionAndAnswer.vue'),
  },
  {
    path: '/client',
    name: 'client',
    meta: {
      title: '的小窝_烘培帮',
      hideTabBar: false,
    },
    component: () => import('../views/Client.vue'),
  },
  {
    path: '/search',
    name: 'search',
    meta: {
      title: '搜索_烘培帮',
      hideTabBar: true,
    },
    component: () => import('../views/Search.vue'),
  },
  {
    path: '/remind',
    name: 'remind',
    redirect: '/remind/all',
    meta: {
      title: '消息_烘培帮',
      hideTabBar: true,
    },
    component: () => import('../views/remind/index.vue'),
    children: [
      {
        path: 'all',
        name: 'all',
        meta: {
          title: '消息_烘培帮',
          hideTabBar: true,
        },
        component: () => import('../views/remind/All.vue'),
      },
      {
        path: 'comment',
        name: 'comment',
        meta: {
          title: '评论消息_烘培帮',
          hideTabBar: true,
        },
        component: () => import('../views/remind/Comment.vue'),
      },
      {
        path: 'other',
        name: 'other',
        meta: {
          title: '点赞消息_烘培帮',
          hideTabBar: true,
        },
        component: () => import('../views/remind/Other.vue'),
      },
      {
        path: 'reward',
        name: 'reward',
        meta: {
          title: '打赏消息_烘培帮',
          hideTabBar: true,
        },
        component: () => import('../views/remind/Reward.vue'),
      },
      {
        path: 'question',
        name: 'question',
        meta: {
          title: '问答消息_烘培帮',
          hideTabBar: true,
        },
        component: () => import('../views/remind/Question.vue'),
      },
      {
        path: 'letter',
        name: 'letter',
        meta: {
          title: '官方消息_烘培帮',
          hideTabBar: true,
        },
        component: () => import('../views/remind/Letter.vue'),
      },
    ],
  },
  {
    path: '/baike',
    name: 'baike',
    meta: {
      title: '烘培百科',
      hideTabBar: true,
    },
    component: () => import('../views/Baike.vue'),
  },
  {
    path: '/university',
    name: 'university',
    meta: {
      title: '烘培帮学堂',
      hideTabBar: true,
    },
    component: () => import('../views/University.vue'),
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login.vue'),
  },
  {
    path: '/map',
    name: 'Map',
    component: () => import('../views/Map.vue'),
  },
  {
    path: '/spxt',
    name: 'spxt',
    component: () => import(/* webpackChunkName: "spxt" */ '@/views/SpxtView.vue'),
  },
  {
    path: '/dier',
    name: 'dier',
    component: () => import('../views/Dier.vue'),
  },
  {
    path: '/person',
    name: 'person',
    component: () => import('../views/Person.vue'),
  },
  {
    path: '/me',
    name: 'me',
    component: () => import('../views/Me.vue'),
  },
  {
    path: '/set',
    name: 'set',
    component: () => import('../views/Set.vue'),
  },
  {
    path: '/about',
    name: 'about',
    component: () => import(/* webpackChunkName: "about" */ '@/views/About.vue'),
  },
  {
    path: '/paixu',
    name: 'routeName',
    component: () => import('../views/Paixu.vue'),
  },
  {
    path: '/fenlei',
    name: 'fenlei',
    component: () => import('../views/Fenlei.vue'),
    children: [
      {
        path: '/childer',
        name: 'childer',
        component: () => import('../views/childer.vue'),
      },
      {
        path: '/login',
        component: () => import('../views/Login.vue'),
      },
      {
        path: '/register',
        component: () => import('../views/Register.vue'),
      },
      {
        path: '/goutong',
        component: () => import('../views/Goutong.vue'),
      },
    ],
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
})

export default router
